package de.tudarmstadt.ukp.wikisniffer.userstudy.util;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;

import de.tudarmstadt.ukp.wikisniffer.userstudy.datastore.ResultStore.Task;

public class Question {
	
	private String question;
	private String id;
	private String correctAnswer;
	private List<String> answers;
	
	public Question(String line){
		String[] splitLine = line.split("\t");

		if(splitLine.length != 6){
			System.err.println("Line does not look familar: " + line);
			return;
		}
		
		this.id 			= splitLine[0];
		this.question 		= splitLine[1];
		this.correctAnswer 	= splitLine[2];
		this.answers 		= new ArrayList<String>(4);		
		this.answers.add(splitLine[2]);
		this.answers.add(splitLine[3]);
		this.answers.add(splitLine[4]);
		this.answers.add(splitLine[5]);
	}

	public String getQuestion() {
		return question;
	}

	public String getId() {
		return id;
	}

	public String getCorrectAnswer() {
		return correctAnswer;
	}

	public String[] getRandomAnswers() {
		String[] randomAnswers = new String[4];
		
		List<String> answers = new ArrayList<String>();
		answers.addAll(this.answers);
		
		Random random = new Random();
		
		for(int n=0;n<4;n++){
			int randomInt = random.nextInt(answers.size());
			randomAnswers[n] = answers.get(randomInt);
			answers.remove(randomInt);
		}

		return randomAnswers;
	}
	
}
